import RestResult from "../rest/RestResult.js";
import config from "../config.js";
import express from 'express';
const app = express();

app.post('/websocket/send', (request, response) => {
    let body = '';
    request.on('data', chunk => {
        body += chunk.toString();
    });

    request.on('end', () => {
        let json = JSON.parse(body);
        emitter.emit("websocketSend",json);
        response.send(JSON.stringify(RestResult.success(json,"sendSuccess","Send Success")));
    })
});

const PORT = config.web.port;
app.listen(PORT, () => {
    console.log(`HTTP端口 ${PORT}`);
});

export default app;